package com.yerbamateprimer.advice.impl;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.google.common.base.Preconditions;
import com.yerbamateprimer.advice.SingleReceptorAdvice;
import com.yerbamateprimer.model.User;

/**
 * This class models an advice
 * to let a user know that he
 * are invited to a round by
 * another user.
 * 
 * @author Matias Liwski
 * @version 1.0
 */
public class UserInvitationToRoundAdvice implements SingleReceptorAdvice {
	private static final long serialVersionUID = -9114193484874711196L;
	private User receptor;
	private User invitingUser;

	/**
	 * @param receptor The receptor of the advice.
	 * @param invitingUser The inviting user.
	 */
	public UserInvitationToRoundAdvice(User receptor, User invitingUser) {
		setAdviceReceptor(receptor);
		setInvitingUser(invitingUser);
	}

	/* (non-Javadoc)
	 * @see com.yerbamateprimer.advice.SingleReceptorAdvice#setReceptor(com.yerbamateprimer.model.User)
	 */
	@Override
	public void setAdviceReceptor(User adviceReceptor) {
		Preconditions.checkArgument(adviceReceptor != null, "This advice need a receptor.");
		this.receptor = adviceReceptor;
	}

	/* (non-Javadoc)
	 * @see com.yerbamateprimer.advice.SingleReceptorAdvice#getReceptor()
	 */
	@Override
	public User getAdviceReceptor() {
		return this.receptor;
	}

	/**
	 * @param invitingUser The inviting user to set.
	 */
	public void setInvitingUser(User invitingUser) {
		Preconditions.checkArgument(invitingUser != null, "This advice need to know who are inviting to round.");
		this.invitingUser = invitingUser;
	}

	/**
	 * @return The inviting user.
	 */
	public User getInvitingUser() {
		return invitingUser;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE, false, false);
	}
}